<!DOCTYPE HTML>
<html>
<head>
    <head>
    <#include "../common/_meta.html">
        <title>个人信息</title>
    </head>

    <style>
        /*修改提示文字的颜色*/
        input::-webkit-input-placeholder { /* WebKit browsers */
            color: red;
        }
        input:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
            color: red;
        }
        input::-moz-placeholder { /* Mozilla Firefox 19+ */
            color: red;
        }
        input:-ms-input-placeholder { /* Internet Explorer 10+ */
            color: red;
        }
    </style>
</head>
<body>
<article class="cl pd-20">
    <form class="form form-horizontal" id="from-add-user">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">用户名：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" style="background-color: #EEEEEE;" value="${user.name}" readonly id="name" name="name">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">等级：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" style="display: none;" value="${user.level}" readonly id="level" name="level">
                <input type="text" class="input-text" style="background-color: #EEEEEE;" value="${user.levelName}" readonly id="levelName" name="levelName">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">昵称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text"  value="${user.nickName}" id="nickName" name="nickName">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">新密码：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="password" class="input-text" autocomplete="off" placeholder="不修改请留空"
                       name="pwd" id="pwd">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">确认密码：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="password" class="input-text" autocomplete="off" placeholder="不修改请留空"
                       name="pwd2" id="pwd2">
            </div>
        </div>
        <#--<div class="row cl">-->
            <#--<label class="form-label col-xs-4 col-sm-3">已授权集群：</label>-->
            <#--<div class="formControls col-xs-8 col-sm-9">-->
                <#--<div id = "clusterList">-->
                <#--<#if clusters?exists && clusters?size gt 0>-->
                    <#--<#list clusters as c>-->
                        <#--<ul>-->
                            <#--<li>${c}</li>-->
                        <#--</ul>-->
                    <#--</#list>-->
                <#--<#elseif user.level lt 2>-->
                    <#--<ul>-->
                        <#--<li>所有集群</li>-->
                    <#--</ul>-->
                <#--<#else>-->
                    <#--<ul>-->
                        <#--<li>请联系管理员申请集群授权</li>-->
                    <#--</ul>-->
                <#--</#if>-->
                <#--</div>-->
            <#--</div>-->
        <#--</div>-->
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

<#include "../common/_footer.html">

<script type="text/javascript">

    window.onload = function () {
        $("#from-add-user").validate({
            rules:{
                pwd:{
                    minlength:6,
                    maxlength:16
                },
                pwd2:{
                    minlength:6,
                    maxlength:16,
                    equalTo: "#pwd"
                },
            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(){
                invoke();
            }
        });
    }

    /* 用户信息修改 */
    function invoke() {
        var index = layer.load(2);
        $.ajax({
            type: "POST",
            url: "${base}/user/info/update",
            data: $('#from-add-user').serialize(),
            dataType: "json",
            success: function (result) {
                layer.close(index);
                if(result.code == 0) {
                    layer.msg("修改成功", {icon:6,time:1000}, function () { layer_close();});
                } else {
                    layer.alert("修改失败", {icon:5,time:1000}, function () {layer_close();});
                }
            },
            error: function () {
                layer.close(index);
                layer.msg("内部错误", {icon:5,time:1000}, function () {layer_close();});
            }
        });
    }
</script>
</body>
</html>